package com.csg.web.interceptor;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

/**
 * 自定义切片
 *
 * @author george
 */
@Slf4j
@Aspect
@Component
public class CustomAspect {

    /**
     * 切片拦截方法
     *
     * @param joinPoint
     * @return
     * @throws Throwable
     */
    @Around("execution(* com.csg.web.demo.controller.*.*(..))")
    public Object handleControllerMethod(ProceedingJoinPoint joinPoint) throws Throwable {
        log.info("Custom Aspect start");
        long startTime = System.currentTimeMillis();
        Object object = joinPoint.proceed();
        long endTime = System.currentTimeMillis();
        log.info("Custom Aspect 耗时：" + (endTime - startTime));
        log.info("Custom Aspect end");
        return object;
    }
}
